package hello.configuration.filter;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @Description:
 * @Author: m01
 * @Date: created at  2018/12/20  17:03
 * @Modified By:
 */
public class CharacterFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("  CharacterFilter  init  ");
    }

    @Override
    public void destroy() {
        System.out.println("  CharacterFilter  destroy  ");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("  CharacterFilter  doFilter  ");
        String city = ((HttpServletRequest) servletRequest).getParameter("city");

        System.out.println("city  " + city);
        filterChain.doFilter(servletRequest, servletResponse);
    }
}
